<table id="term_list" class="itable">
  <thead>
    <tr>
      <th>名称</th>
      <th>排序</th>
      <th>操作</th>
    </tr>
  </thead>
  <tbody>
    
	<{foreach from=$tree item=item}>
		<tr>
			<td><div style="float:left; width:<{$item.preWidth}>px;">&nbsp;</div><div style="width:300px;float:left;" class="edit" id="<{$item.tid}>"><{$item.name}></div></td>
			<td><div class="edit_weight" id="<{$item.tid}>"><{$item.weight}></div></td>
			<td><a href="javascript:void(0)" onclick="del_term(<{$item.tid}>)">删除</a></td>
		</tr>
	<{/foreach}>
    
  </tbody>
</table>
<script type="text/javascript">
$('#term_list tr:even').addClass('even');
$('#term_list tr:odd').addClass('odd');
$('.edit').editable('admin.php?ctrl=vocabulary&act=edit_submit', { 
    cancel    : '取消',
    submit    : '保存',
    tooltip   : 'Click to edit...'
});
$('.edit_weight').editable('admin.php?ctrl=vocabulary&act=edit_weight', { 
    cancel    : '取消',
    submit    : '保存',
    tooltip   : 'Click to edit...'
});
function del_term(tid){
	if(confirm('确定删除术语?')){
		$.ajax({
      type: "POST",
      url: "admin.php?ctrl=vocabulary&act=term_delete",
      data: "tid="+tid,
      timeout: 20000,
      error: function(){alert('error');},
      success: function(result){
        if(result == '1'){
        	$('#vocabulary_tabs').tabs( "load" , 0 );
        }else if(result == '-1'){
          alert('删除失败');
        }else if(result == '-2'){
          alert('术语不存在');
        }else if(result == '-3'){
          alert('参数错误');
        }else{
        	alert('未知错误'+result);
        }
      }
    });
	}
}

function term_list_by_parent(vid, tid){
	$taxonomy_tabs.tabs( "url" , 2 , 'admin.php?ctrl=taxonomy&act=term_list&vid='+vid+'&parent='+tid );
	$taxonomy_tabs.tabs( "load" , 2 );
}

function term_add_by_parent(vid, tid){
	$taxonomy_tabs.tabs( "url" , 3 , 'admin.php?ctrl=taxonomy&act=term_add&vid='+vid +"&tid="+tid);
	$taxonomy_tabs.tabs( "select" , 3 );
}
</script>